	
/****** Object:  Stored Procedure USERInsert    Script Date: Monday, December 10, 2007 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[spUSERInsert]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [spUSERInsert]
GO

	
	

/******************************************************************************
**		File: 
**		Name: spUSERInsert
**		Desc: 
**
**		Return values:
** 
**		Called by:   
**              
**		Parameters:
**		Input							Output
**     ----------							-----------
**
**		Auth: CodeSmith
**		Date: 12/10/2007 10:20:44 PM
*******************************************************************************
**		Change History
*******************************************************************************
**		Date:		Author:				Description:
**		--------		--------				-------------------------------------------
**    
*******************************************************************************/
CREATE PROCEDURE spUSERInsert
	@NAME varchar(50),
	@LOGIN_NAME varchar(20),
	@PASSWORD varchar(50),
	@EMAIL varchar(50),
	@USER_TYPE tinyint,
	@CUSTOMER_CODE varchar(20),
	@BAR_CODE varchar(7),
	@IS_ADMIN bit,
	@IS_ENABLED bit,
	@CREATED_DATE datetime,
	@CREATED_BY int,
	@UPDATED_DATE datetime,
	@UPDATED_BY int,
	@CHANGE_PWD_GUID uniqueidentifier,
	@SORT_REFERENCE1 varchar(20),
	@SORT_REFERENCE2 varchar(20),
	@DOWNLOADABLE_CSV bit,
	@ActiveOfficeID int,
	@CountryID int,
	@US_ID_PK int output
AS

INSERT INTO [USER] 
(
	[NAME],
	[LOGIN_NAME],
	[PASSWORD],
	[EMAIL],
	[USER_TYPE],
	[CUSTOMER_CODE],
	[BAR_CODE],
	[IS_ADMIN],
	[IS_ENABLED],
	[CREATED_DATE],
	[CREATED_BY],
	[UPDATED_DATE],
	[UPDATED_BY],
	[CHANGE_PWD_GUID],
	[SORT_REFERENCE1],
	[SORT_REFERENCE2],
	[DOWNLOADABLE_CSV],
	[ActiveOfficeID],
	[CountryID]
) 
VALUES 
(
	@NAME,
	@LOGIN_NAME,
	@PASSWORD,
	@EMAIL,
	@USER_TYPE,
	@CUSTOMER_CODE,
	@BAR_CODE,
	@IS_ADMIN,
	@IS_ENABLED,
	@CREATED_DATE,
	@CREATED_BY,
	@UPDATED_DATE,
	@UPDATED_BY,
	@CHANGE_PWD_GUID,
	@SORT_REFERENCE1,
	@SORT_REFERENCE2,
	@DOWNLOADABLE_CSV,
	@ActiveOfficeID,
	@CountryID
)

SELECT @US_ID_PK = @@IDENTITY

GO
	
